package Concurrent.countDownLatch.notice.condition;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by wangyg6 on 2017/11/29.
 */
public class TaskOne implements Runnable {
	private ReentrantLock lock;
	private Condition one;

	public TaskOne(ReentrantLock lock, Condition one) {
		this.lock = lock;
		this.one = one;
	}

	@Override
	public void run() {
		lock.lock();
		try {
			Thread.sleep((long) (Math.random() * 1000));
			System.out.println("Task one execute complete");
			one.signal();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}finally {
			lock.unlock();
		}
	}
}
